home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Template instantiation
- Date: 2 Mar 1996 00:16:32 GMT
- Organization: Borland International
- Message-ID: <4h8411$q8k@druid.borland.com>
- References: <37116784wnr@parkbayl.demon.co.uk>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <37116784wnr@parkbayl.demon.co.uk>, martin@parkbayl.demon.co.uk
- says...
- >
- >Can anyone tell me if its possible to instantiate a template with a class
- >that is in itself a template.
- >
- >i.e. I have two classes
- >
- >template <class T>
- >class Node
- >{
- > .. omitted..
- >private:
- > T* nodeObject;
- >};
- >
- >template <class X>
- >class Queue
- >{
- > ... omitted ...
- >private:
- > X* queueObject;
- >};
- >
- >Queue<Node<int>> myQueue; // Crazy as it may seem
- > // this doesn't work
- >
- >i.e. I want to instantiate a Queue object which holds pointers to Node
- >objects which hold pointers to ints.
- >
- >Am I on another planet??!
-
- Nope, just not playing compiler properly. Being human, you read that
- declaration as involving two templates. The compiler, not being human, read it
- literally, saw a >> operator, and concluded that nothing after that point made
- any sense. Unfortunately, the compiler is right. Put a space between the two
- >s and the compiler will read it the same way you do.
- -- Pete
-
-